"use strict";

const { getBaseDir } = require("ee-core/ps");
const path = require("path");
const Store = require("electron-store");


/**
 * 系统元数据服务
 * @class
 */
class MetadbService {
  constructor() {   

    this.store = new Store({ name: "settings"});
  }

  async getSettingMeta(key) { 
    const mataStore = new Store({
       cwd: path.join( getBaseDir(), "public/meta" ),
       name: "dict" });
    let data = mataStore.get(key);  
    if (data === undefined || data === null) {
      data = [];
    }
    return data;
  }

  async getUserSetting(key) {    
    let data = this.store.get(key);
    if (data === undefined || data === null) {
      data = [];
    }
    return data;
  }

  async saveUserSetting(key, val) {
    this.store.set(key, val);
  } 

}

MetadbService.toString = () => "[class MetadbService]";
module.exports = {
  MetadbService,
  metadbService: new MetadbService()
};
